#include <iostream>
using namespace std;

int max(int totalNum, ...)
{
    va_list argp;
    int para = 0;
    va_start(argp, totalNum);
    int maxNum = va_arg(argp, int);

    for (int i = 1; i < totalNum; i++)
    {
        para = va_arg(argp, int);
        if (maxNum < para)
            maxNum = para;
    }
    va_end(argp);
    return maxNum;
}

int min(int totalNum, ...)
{
    va_list argp;
    int para = 0;
    va_start(argp, totalNum);
    int minNum = va_arg(argp, int);

    for (int i = 1; i < totalNum; i++)
    {
        para = va_arg(argp, int);
        if (minNum > para)
            minNum = para;
    }
    va_end(argp);
    return minNum;
}

int dif(int totalNum, int x, int y, int z)
{
    return max(totalNum, x, y, z) - min(totalNum, x, y, z);
}

int main()
{
    cout << endl
         << "学号：3170608043，姓名：石英钰" << endl
         << endl;
    cout << "Features: 函数的嵌套调用, 求3个数中最大数和最小树的差值" << endl
         << endl;

    int x = 0, y = 0, z = 0;
    cout << "请输入三个数: ";
    cin >> x >> y >> z;

    cout << "3个数中最大数和最小树的差值为: " << dif(3, x, y, z) << endl;
}